﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TIENITCodeGener
{
    public partial class frmReg : Form
    {

#region "Constructor"
        public frmReg()
        {
            InitializeComponent();
            ITFACommon.SetFormIcon(this);
        }
#endregion

#region "Form Events"
        private void frmReg_Load(object sender, EventArgs e)
        {
            try
            {
                SetSoftwareID();
            }
            catch
            {            	
            }
        }

        private void frmReg_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
            }
        }
#endregion

#region "Registration"
        private void SetSoftwareID()
        {
            string[] arr = e.b(f.b(TIENITCodeGener.Properties.Settings.Default.SoftwareName + Application.ProductVersion.Replace(".","")));
            string sID = arr[0] + "-" + arr[1] + "-" + arr[2] + "-" + arr[3] + "-" + arr[4];
            txt_Info_SoftwareID.Text = sID;
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                string userInputKey = txt_Info_Key.Text.Replace("-","");
                string baseStringUser = txt_Info_SoftwareID.Text.Replace("-", "");
                bool bCheck = f.a(baseStringUser, userInputKey);
                if (bCheck == true)
                {
                    btnRegister.Enabled = false;
                    lblStatus.Text = "Code Gener 3.0.6.6  FULL  Version";
                    TIENITCodeGener.Properties.Settings.Default.SerialKeyTienitGenerator = userInputKey;
                    TIENITCodeGener.Properties.Settings.Default.Mode_App = "FULL";
                    TIENITCodeGener.Properties.Settings.Default.Save();
                    ITFACommon.IS_REGISTERED = true;
                    ITFACommon.Message_Information("You need to restart application !");
                    Application.Restart();
                }
                else
                {
                    ITFACommon.Message_Information("Registration Key Invalid. " + Environment.NewLine + "Please contact us via information above." + Environment.NewLine + "Thanks !");
                }
            }
            catch
            {
            }
        }
#endregion

    }
}
